﻿using System;
using System.Xml.Linq;

namespace SharePoint.Orm.Caml {
	public abstract class CamlExpr {
		public abstract XObject ToXml();

		public static CamlExpr Parse(XElement element) {
			if (CamlLogicalOp.IsLogicalOp(element)) {
				return CamlLogicalOp.Parse(element);
			}
			if (CamlComparisonOp.IsComparisonOp(element)) {
				return CamlComparisonOp.Parse(element);
			}
			throw new Exception("Unexpected element '" + element.Name + "'");
		}
	}
}
